﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CPF.StandardTetris
{
    public partial class GAdata : Form
    {
        public GAdata()
        {
            InitializeComponent();
        }
        // Delegates to enable async calls for setting controls properties
        private delegate void SetTextCallback(System.Windows.Forms.Control control, string text);

        // Thread safe updating of control's text property
        private void SetText(System.Windows.Forms.Control control, string text)
        {
            if (control.InvokeRequired)
            {
                SetTextCallback d = new SetTextCallback(SetText);
                Invoke(d, new object[] { control, text });
            }
            else
            {
                control.Text = text;
            }
        }
        public void UpdateIterationNumber(string text)
        {
            if (lblIteration.InvokeRequired)
            {
                SetTextCallback d = new SetTextCallback(SetText);
                Invoke(d, new object[] { lblIteration, text });
            }
            else
            {
                lblIteration.Text = text;
            }
        }
        public void UpdateBestChromosome(string text)
        {
            if (lblIteration.InvokeRequired)
            {
                SetTextCallback d = new SetTextCallback(SetText);
                Invoke(d, new object[] { lblBestChromosome, text });
            }
            else
            {
                lblBestChromosome.Text = text;
            }
        }
        public void UpdateScore(string text)
        {
            if (lblIteration.InvokeRequired)
            {
                SetTextCallback d = new SetTextCallback(SetText);
                Invoke(d, new object[] { lblScore, text });
            }
            else
            {
                lblScore.Text = text;
            }
        }

        private void GAdata_Load(object sender, EventArgs e)
        {

        }
    }
}
